package com.tuling.designpattern.strategy;

import java.util.Scanner;

/**
 * @author it-小林
 * @desc   客户端
 * @date 2021年09月28日 9:58
 */
public class Client {
    public static void main(String[] args) {
        CashContext context = null;

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入打折方式（1/2/3）:");
        int in = scanner.nextInt();
        String type = "";

        switch (in) {
            case 1:
                context = new CashContext(new CashNormal());
                type += "正常收费";
                break;
            case 2:
                context = new CashContext(new CashReturn(300, 200));
                type += "满300返200";
                break;
            case 3:
                context = new CashContext(new CashRebate(0.8));
                type += "打8折";
                break;
            default:
                System.out.println("请输入1/2/3");
                break;
        }

        double totalPrices = 0;
        System.out.print("请输入单价：");
        double price = scanner.nextDouble();
        System.out.print("请输入数量：");
        double num = scanner.nextDouble();
        totalPrices = context.getResult(price * num);
        System.out.println("单价：" + price + "，数量：" + num + "，类型：" + type + "，合计：" + totalPrices);
    }
}
